<? include('header_html.php');
$tab = $nms->getSubTab();

?>
<div id="body">
	<div id="tabPanel">
		<div class="tabs">
		<a href="/devices/" class="<?=empty($tab)?'active':''?>">All</a>
<? foreach ($nms->getDeviceTypes() AS $deviceType) {
	echo '<a href="/devices/'.$deviceType->type.'/" class="'.($deviceType->type==$tab?'active':'').'">'.$deviceType->description.'</a>'; 
}?>		
			<div class="search">
				<input type="text" name="q" value="Search Devices...."/>
			</div>
		</div>
<? $nms->timerEvent('End Tab Headers'); ?>
		<div class="tab">
			<div class="header">
				
				<span class="right uptime">Uptime</span>
				<span class="right metrics" >Utilisation Metrics</span>
				<span>Description</span>
			</div>
<? 	
	$odd = false;
	$devices = $nms->getDevices(array('type'=>$tab));
	$nms->timerEvent('Loaded Devices');
	foreach ($devices AS $device) { 
		$nms->timerEvent('Device '.$device->id);
		$device->os->getResources();
		echo '<a href="/device/'.$device->id.'/" class="device '.($device->disabled?'status disabled':($device->isUp()?'status up':'status down')).' '.($odd?'odd':'').'">';
		echo '	<span class="info">';
		if (!empty($device->cpus)) {
			echo '		<span class="cpus"><img src="/graph.php?device='.$device->id.'&type=deviceProcessorUsage&width=100&height=30&bg=fff" graph="device='.$device->id.'&type=deviceProcessorUsage"/>Processor Load</span>';
		}
		if (!empty($device->interfaces)) {
			echo '		<span class="interfaces"><img src="/graph.php?device='.$device->id.'&type=deviceTraffic&width=100&height=30&legend=0&bg=fff" graph="device='.$device->id.'&type=deviceTraffic"/>Interface Traffic</span>';
		}
		if (!empty($device->services)) {
			echo '		<span class="services"><img src="img/1x1.png"/>	Serivces</span>';
		}
		echo '		<span class="uptime">'.$device->getUptime().'</span>';
		echo '	</span>';
		echo '	<img src="/img/device/'.$device->os->getType().'.png" class="icon"  />';
		echo '	<b>'.$device->description.'</b>';
		echo '	<span>'.$device->getHostName().' - '.$device->location.'</span>';
		echo '</a>';
		$odd = !$odd;
	}
?>	
		</div>
	</div>
<script type="text/javascript">
	$('*[graph]').tooltip({ 
		track: true, 
		delay: 2000, 
		showURL: false, 
		bodyHandler: function() { 
			return $("<img/>").attr({
				src:'/graph.php?width=600&height=400&legend=1&font=fff&frame=fff&'+this.getAttribute('graph'),
				width:600,
				height:400
			}); 
		},
		fade: 100,
		extraClass: 'graph'
	}).click(function () {
		window.location.href='/graph/?width=1200&height=800&legend=1&'+this.getAttribute('graph');	
	});
</script>
</div>
<? include('footer_html.php'); ?>